package com.lanjiu.lib.utils;

/**
 * @description:
 * @author: Panwei
 * @date: 2020/3/12 19:54
 */
public class ParseUtils {

    ParseUtils() {
    }

    public static int parseInt(String string) {
        return parseInt(string, 0);
    }

    public static int parseInt(String string, int def) {
        try {
            return Integer.parseInt(string);
        } catch (NumberFormatException e) {
            return def;
        }
    }

    public static boolean parseBoolean(String string) {
        return parseBoolean(string, false);
    }

    public static boolean parseBoolean(String string, boolean def) {
        try {
            return Boolean.parseBoolean(string);
        } catch (Exception e) {
            return def;
        }
    }
}
